package utils;

import entry.Enterprise;
import entry.Instituty;
import entry.Ticket_open;
import pojo.XianShi;
import service.EnterpriseService;
import service.InstitutyService;
import service.impl.EnterpriseServiceImpl;
import service.impl.InstitutyServiceImpl;

import java.util.ArrayList;
@SuppressWarnings("all")
public class PojoUtils {

    public static ArrayList<XianShi> pojo(ArrayList<Ticket_open> list) {
        EnterpriseService enterpriseService = new EnterpriseServiceImpl();
        InstitutyService institutyService = new InstitutyServiceImpl();
        ArrayList<XianShi> xianShi = new ArrayList<>(list.size());
        for (int i = 0; i < list.size(); i++) {
            XianShi xianShiItem = new XianShi();
            Instituty instName = institutyService.selectNameById(list.get(i).getInstituty_id());
            Enterprise topen = enterpriseService.selectNameById(list.get(i).getEnterprise_id());
            Enterprise acquTopen1 = enterpriseService.selectNameById(list.get(i).getAcquire_enterprise_id());

            xianShiItem.setNo(list.get(i).getNo());
            xianShiItem.setAmount(list.get(i).getAmount());
            xianShiItem.setKaidanTime(list.get(i).getCreate_time());
            if (list.get(i).getStatus().equals("开单中")){
                xianShiItem.setStatus("<td class=\"am-hide-sm-only\">\n" +
                        "<span class=\"ele-dot-status ele-dot-status-info\"><span>\n" +
                        "<span class=\"ele-dot-text\" style=\"width: 80px;\">开单中</span>\n" +
                        "<td>");
            }else if (list.get(i).getStatus().equals("成功")){
                xianShiItem.setStatus("<td class=\"am-hide-sm-only\">\n" +
                        "<span class=\"ele-dot-status ele-dot-status-success\"><span>\n" +
                        "<span class=\"ele-dot-text\" style=\"width: 80px;\">成功</span>\n" +
                        "<td>");
            }else if (list.get(i).getStatus().equals("复核未通过")){
                xianShiItem.setStatus("<td class=\"am-hide-sm-only\">\n" +
                        "<span class=\"ele-dot-status ele-dot-status-error\"><span>\n" +
                        "<span class=\"ele-dot-text\" style=\"width: 80px;\">复核未通过</span>\n" +
                        "<td>");
            }else {
                xianShiItem.setStatus("<td class=\"am-hide-sm-only\">\n" +
                        "<span class=\"ele-dot-status ele-dot-status-error\"><span>\n" +
                        "<span class=\"ele-dot-text\" style=\"width: 80px;\">已撤销</span>\n" +
                        "<td>");
            }
            xianShiItem.setShangLian(list.get(i).getUplink_address());
            xianShiItem.setShouDanTime(list.get(i).getExpiry_time());
            xianShiItem.setInstituName(instName.getName());
            xianShiItem.setKaiDanName(topen.getName());
            xianShiItem.setShouDanName(acquTopen1.getName());
            if (list.get(i).getStatus().equals("开单中")) {
                xianShiItem.setOperate("<a href=\"javascript:void(0);\">详情</a>&nbsp;<a href=\"javascript:void(0);\">撤销</a>");
            }else if (list.get(i).getStatus().equals("已撤销")){
                xianShiItem.setOperate("<a href=\"javascript:void(0);\">详情</a>&nbsp;<a href=\"javascript:void(0);\">重新申请</a>");
            }else if (list.get(i).getStatus().equals("成功")){
                xianShiItem.setOperate("<a href=\"javascript:void(0);\">详情</a>");
            }else {
                xianShiItem.setOperate("<a href=\"javascript:void(0);\">详情</a>&nbsp;<a href=\"javascript:void(0);\">重新申请</a>");
            }
            xianShi.add(xianShiItem);
        }
        return xianShi;
    }


    public static ArrayList<XianShi> pojo1(ArrayList<Ticket_open> list) {
        EnterpriseService enterpriseService = new EnterpriseServiceImpl();
        InstitutyService institutyService = new InstitutyServiceImpl();
        ArrayList<XianShi> xianShi = new ArrayList<>(list.size());
        for (int i = 0; i < list.size(); i++) {
            XianShi xianShiItem = new XianShi();
            Instituty instName = institutyService.selectNameById(list.get(i).getInstituty_id());
            Enterprise topen = enterpriseService.selectNameById(list.get(i).getEnterprise_id());
            Enterprise acquTopen1 = enterpriseService.selectNameById(list.get(i).getAcquire_enterprise_id());

            xianShiItem.setNo(list.get(i).getNo());
            xianShiItem.setAmount(list.get(i).getAmount());
            xianShiItem.setKaidanTime(list.get(i).getCreate_time());
            xianShiItem.setShangLian(list.get(i).getUplink_address());
            xianShiItem.setShouDanTime(list.get(i).getExpiry_time());
            xianShiItem.setInstituName(instName.getName());
            xianShiItem.setKaiDanName(topen.getName());
            xianShiItem.setShouDanName(acquTopen1.getName());
            if (list.get(i).getStatus().equals("开单中")) {
                xianShiItem.setOperate("<a href=\"javascript:void(0);\">复核</a>");
            }
            xianShi.add(xianShiItem);
        }
        return xianShi;
    }
}
